package com.huike.web.controller.operLog;

import com.huike.common.core.controller.BaseController;
import com.huike.common.core.domain.AjaxResult;
import com.huike.common.core.domain.PageAjaxResult;
import com.huike.common.core.page.PageDomain;
import com.huike.common.core.page.PageResult;
import com.huike.generator.service.operLogService;
import com.huike.common.core.page.OperLogPageQueryDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;


import javax.annotation.Resource;
import java.util.List;

@Api("操作日志")
@Slf4j
@RequestMapping("/monitor/operlog")
@RestController
public class operLogController extends BaseController {

    @Resource
    private operLogService operLogService;


    @ApiOperation("查询操作日志列表")
    @PreAuthorize("@ss.hasPermi('system:user:list')")
    @GetMapping("/list")
    public PageAjaxResult list(OperLogPageQueryDto dto){
        //startPage();
        PageResult pageResult = operLogService.selectList(dto);
//        log.info("查询操作日志列表{}", list);
        PageAjaxResult pageAjaxResult = PageAjaxResult.success();
        pageAjaxResult.setRows(pageResult.getRecords());
        pageAjaxResult.setTotal(pageResult.getTotal());
        return pageAjaxResult;
    }

    @ApiOperation("删除日志")
    @DeleteMapping("/{operIds}")
    public AjaxResult delete(@PathVariable("operIds") List<Long> ids) {
        log.info("查询删除id{}", ids);
        operLogService.deletedByList(ids);
        return AjaxResult.success();
    }

    @ApiOperation("清空日志")
    @DeleteMapping("/clean")
    public AjaxResult deleteAll() {
        operLogService.deletedAll();
        return AjaxResult.success();
    }

    @ApiOperation("操作日志导出")
    @GetMapping("/export")
    public AjaxResult export() {
        return AjaxResult.success();
    }


}
